/************************************
 * Package: RGcpp					*
 * Authors: Rui Eduardo Gouveia Gil	*
 * Date: 2010						*
 ************************************/
#ifndef __RGCPP_STRINGTOKENIZER_H__
#define __RGCPP_STRINGTOKENIZER_H__

#include <string>
#include <boost/thread/mutex.hpp>

#include "rgcpp/exceptions/RuntimeException.h"

namespace rgcpp
{

class StringTokenizer
{
	private:
		char del;
		std::string str;
		boost::mutex mut;
		unsigned int current;
		std::string strTokens;
		unsigned int elementsCount;

	public:
		StringTokenizer();
		StringTokenizer(const std::string& str);
		StringTokenizer(const std::string& str, char del);
		StringTokenizer(const StringTokenizer &copy);
		~StringTokenizer();

		bool hasMoreElements();

		std::string nextToken();
		int nextTokenInt();
		float nextTokenFloat();

		unsigned int countTokens();
		unsigned int countRemainingTokens();

		void reset();

		void operator=(const StringTokenizer &copy)
		{
			this->del = copy.del;
			this->str = copy.str;
			this->current = copy.current;
			this->strTokens = copy.strTokens;
			this->elementsCount = copy.elementsCount;
		}
};

}

#endif
